package leetcode;

import java.util.HashMap;
import java.util.Map;

public class l0217_存在重复元素 {
    public boolean containsDuplicate(int[] nums) {
        Map<Integer, Integer> dataMap = new HashMap<>();
        for (int num : nums) {
            Integer count = dataMap.getOrDefault(num, 0);
            //已出现过一次了,直接阻断
            if (count == 1) {
                return true;
            }
            dataMap.put(num, count + 1);
        }
        return false;
    }

}
